package com.mars.basic.config;

import com.rp.spring.jpa.FreemarkerSqlTemplates;
import com.rp.spring.jpa.GenericJpaRepositoryFactoryBean;
import com.rp.spring.jpa.GenericJpaRepositoryImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.web.config.EnableSpringDataWebSupport;

/**
 * 
 * title: JpaConfig.java 
 * jpa通用配置
 *
 * @author rplees
 * @email rplees.i.ly@gmail.com
 * @version 1.0  
 * @created Jan 26, 2018 3:57:59 PM
 */
@Configuration
@EnableSpringDataWebSupport
@EnableJpaRepositories(
		repositoryBaseClass = GenericJpaRepositoryImpl.class, 
		repositoryFactoryBeanClass = GenericJpaRepositoryFactoryBean.class,
        basePackages = { "com.mars.**.po", "com.mars.**.repo" })
@EntityScan({ "com.mars.**.po", "com.mars.**.repo" })
public class JpaConfig {
	@Bean
	@ConditionalOnMissingBean
	public FreemarkerSqlTemplates freemarkerSqlTemplates() {
		FreemarkerSqlTemplates templates = new FreemarkerSqlTemplates();
		templates.setTemplateBasePackage("");
		templates.setSuffix(".sftl");
		return templates;
	}
}